package string;

/**
 * int indexof(String str)
 * 检索给定字符串在当前字符串中的位置,如果当前字符串不包含当前内容则返回-1
 */
public class IndexOfDemo {
    public static void main(String[] args) {
        String line ="thinking in java";
        int index = line.indexOf("in");
        System.out.println(index);//2

        index = line.indexOf("IN");//不含有给定内容时返回-1
        System.out.println(index);//-1

        index = line.indexOf("in",2);
        System.out.println(index);
        index = line.indexOf("in",3);
        System.out.println(index);
        index = line.lastIndexOf("in");
        System.out.println(index);
    }
}
